package com.trover.myapplication.core.http.apimodel

import java.lang.Error
import java.lang.Exception

sealed class Result<out T : Any> {

    data class Success<out T : Any>(val data: T) : Result<T>()

    sealed class Error(val exception: Exception) : Result<Nothing>() {
        class RecoverableError(exception: Exception) : Error(exception)
        class NonRecoverableError(exception: Exception) : Error(exception)
        class NoResponseError(exception: Exception) : Error(exception)
    }

    object InProgress : Result<Nothing>()

    override fun toString(): String {
        return when (this) {
            is Success<*> -> "Success[data=$data]"
            is Error -> exception.message + ""
            is InProgress -> "InProgress[progress=${InProgress}]"
        }
    }
}
